%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/unions-search-entities/search"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 8, 9, 80, 10, 11<br />2: PgSelect[7]<br />3: PgSelectRows[13]<br />4: __ListTransform[12]"):::bucket
    Bucket1("Bucket 1 (subroutine)<br /><br />ROOT PgSelectSingle{1}ᐸentity_searchᐳ[15]"):::bucket
    Bucket2("Bucket 2 (listItem)<br />Deps: 10<br /><br />ROOT __Item{2}ᐸ12ᐳ[16]<br />1: <br />ᐳ: 17, 18, 19, 20, 21<br />2: Lambda[22]<br />ᐳ: Access[23]"):::bucket
    Bucket3("Bucket 3 (polymorphic)<br />__typename: Access[23]<br />Deps: 23, 22, 10"):::bucket
    Bucket4("Bucket 4 (polymorphicPartition)<br />|Person<br />Deps: 22, 10<br />ᐳPerson<br /><br />1: <br />ᐳ: Access[24]<br />2: PgSelect[25]<br />3: PgSelectRows[30]<br />ᐳ: 29, 31, 48, 51"):::bucket
    Bucket5("Bucket 5 (polymorphicPartition)<br />|Post<br />Deps: 22, 10<br />ᐳPost<br /><br />1: <br />ᐳ: Access[32]<br />2: PgSelect[33]<br />3: PgSelectRows[38]<br />ᐳ: 37, 39, 49, 52, 68<br />4: PgSelect[53]<br />5: PgSelectRows[58]<br />ᐳ: First[57], PgSelectSingle[59]"):::bucket
    Bucket6("Bucket 6 (polymorphicPartition)<br />|Comment<br />Deps: 22, 10<br />ᐳComment<br /><br />1: <br />ᐳ: Access[40]<br />2: PgSelect[41]<br />3: PgSelectRows[46]<br />ᐳ: 45, 47, 50, 60, 69, 75<br />4: PgSelect[61], PgSelect[70]<br />5: PgSelectRows[66], PgSelectRows[73]<br />ᐳ: 65, 67, 72, 74"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 59<br /><br />ROOT PgSelectSingle{5}ᐸpeopleᐳ[59]"):::bucket
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 67<br /><br />ROOT PgSelectSingle{6}ᐸpeopleᐳ[67]"):::bucket
    Bucket9("Bucket 9 (nullableBoundary)<br />Deps: 74, 69<br /><br />ROOT PgSelectSingle{6}ᐸpostsᐳ[74]"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket4 & Bucket5 & Bucket6
    Bucket5 --> Bucket7
    Bucket6 --> Bucket8 & Bucket9

    %% plan dependencies
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸentity_searchᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgFromExpression11{{"PgFromExpression[11∈0] ➊<br />More deps:<br />- Constantᐸ'Dave'ᐳ[80]"}}:::plan
    PgFromExpression11 --> PgSelect7
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 7"}}:::plan
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    __ListTransform12[["__ListTransform[12∈0] ➊<br />ᐸeach:7ᐳ<br />More deps:<br />- PgSelectRows[13]"]]:::plan
    PgSelectRows13[["PgSelectRows[13∈0] ➊<br />Dependents: 2"]]:::plan
    PgSelect7 --> PgSelectRows13
    __Item14[/"__Item[14∈1]<br />ᐸ13ᐳ<br />More deps:<br />- PgSelectRows[13]"\]:::itemplan
    PgSelectSingle15{{"PgSelectSingle[15∈1]<br />ᐸentity_searchᐳ"}}:::plan
    __Item14 --> PgSelectSingle15
    List21{{"List[21∈2]<br />ᐸ18,19,20ᐳ"}}:::plan
    PgClassExpression18{{"PgClassExpression[18∈2]<br />ᐸ__entity_s...person_id”ᐳ"}}:::plan
    PgClassExpression19{{"PgClassExpression[19∈2]<br />ᐸ__entity_s....”post_id”ᐳ"}}:::plan
    PgClassExpression20{{"PgClassExpression[20∈2]<br />ᐸ__entity_s...omment_id”ᐳ"}}:::plan
    PgClassExpression18 & PgClassExpression19 & PgClassExpression20 --> List21
    __Item16[/"__Item[16∈2]<br />ᐸ12ᐳ"\]:::itemplan
    __ListTransform12 ==> __Item16
    PgSelectSingle17{{"PgSelectSingle[17∈2]<br />ᐸentity_searchᐳ"}}:::plan
    __Item16 --> PgSelectSingle17
    PgSelectSingle17 --> PgClassExpression18
    PgSelectSingle17 --> PgClassExpression19
    PgSelectSingle17 --> PgClassExpression20
    Lambda22[["Lambda[22∈2]"]]:::unbatchedplan
    List21 --> Lambda22
    Access23{{"Access[23∈2]<br />ᐸ22.__typenameᐳ"}}:::plan
    Lambda22 --> Access23
    PgSelect25[["PgSelect[25∈4]^<br />ᐸpeopleᐳ<br />More deps:<br />- Object[10]"]]:::plan
    Access24{{"Access[24∈4]<br />ᐸ22.person_idᐳ<br />ᐳPerson"}}:::plan
    Access24 --> PgSelect25
    Lambda22 --> Access24
    First29{{"First[29∈4]^"}}:::plan
    PgSelectRows30[["PgSelectRows[30∈4]^"]]:::plan
    PgSelectRows30 --> First29
    PgSelect25 --> PgSelectRows30
    PgSelectSingle31{{"PgSelectSingle[31∈4]^<br />ᐸpeopleᐳ"}}:::plan
    First29 --> PgSelectSingle31
    PgClassExpression48{{"PgClassExpression[48∈4]^<br />ᐸ__people__.”person_id”ᐳ"}}:::plan
    PgSelectSingle31 --> PgClassExpression48
    PgClassExpression51{{"PgClassExpression[51∈4]^<br />ᐸ__people__.”username”ᐳ"}}:::plan
    PgClassExpression48 o--o PgClassExpression51
    PgSelect33[["PgSelect[33∈5]^<br />ᐸpostsᐳ<br />More deps:<br />- Object[10]"]]:::plan
    Access32{{"Access[32∈5]<br />ᐸ22.post_idᐳ<br />ᐳPost"}}:::plan
    Access32 --> PgSelect33
    PgSelect53[["PgSelect[53∈5]^<br />ᐸpeopleᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression52{{"PgClassExpression[52∈5]^<br />ᐸ__posts__.”author_id”ᐳ"}}:::plan
    PgClassExpression52 --> PgSelect53
    Lambda22 --> Access32
    First37{{"First[37∈5]^"}}:::plan
    PgSelectRows38[["PgSelectRows[38∈5]^"]]:::plan
    PgSelectRows38 --> First37
    PgSelect33 --> PgSelectRows38
    PgSelectSingle39{{"PgSelectSingle[39∈5]^<br />ᐸpostsᐳ"}}:::plan
    First37 --> PgSelectSingle39
    PgClassExpression49{{"PgClassExpression[49∈5]^<br />ᐸ__posts__.”post_id”ᐳ"}}:::plan
    PgSelectSingle39 --> PgClassExpression49
    PgSelectSingle39 --> PgClassExpression52
    First57{{"First[57∈5]^"}}:::plan
    PgSelectRows58[["PgSelectRows[58∈5]^"]]:::plan
    PgSelectRows58 --> First57
    PgSelect53 --> PgSelectRows58
    PgSelectSingle59{{"PgSelectSingle[59∈5]^<br />ᐸpeopleᐳ"}}:::plan
    First57 --> PgSelectSingle59
    PgClassExpression68{{"PgClassExpression[68∈5]^<br />ᐸ__posts__.”body”ᐳ"}}:::plan
    PgClassExpression49 o--o PgClassExpression68
    PgSelect41[["PgSelect[41∈6]^<br />ᐸcommentsᐳ<br />More deps:<br />- Object[10]"]]:::plan
    Access40{{"Access[40∈6]<br />ᐸ22.comment_idᐳ<br />ᐳComment"}}:::plan
    Access40 --> PgSelect41
    PgSelect61[["PgSelect[61∈6]^<br />ᐸpeopleᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression60{{"PgClassExpression[60∈6]^<br />ᐸ__comments...author_id”ᐳ"}}:::plan
    PgClassExpression60 --> PgSelect61
    PgSelect70[["PgSelect[70∈6]^<br />ᐸpostsᐳ<br />More deps:<br />- Object[10]"]]:::plan
    PgClassExpression69{{"PgClassExpression[69∈6]^<br />ᐸ__comments__.”post_id”ᐳ"}}:::plan
    PgClassExpression69 --> PgSelect70
    Lambda22 --> Access40
    First45{{"First[45∈6]^"}}:::plan
    PgSelectRows46[["PgSelectRows[46∈6]^"]]:::plan
    PgSelectRows46 --> First45
    PgSelect41 --> PgSelectRows46
    PgSelectSingle47{{"PgSelectSingle[47∈6]^<br />ᐸcommentsᐳ"}}:::plan
    First45 --> PgSelectSingle47
    PgClassExpression50{{"PgClassExpression[50∈6]^<br />ᐸ__comments...omment_id”ᐳ"}}:::plan
    PgSelectSingle47 --> PgClassExpression50
    PgSelectSingle47 --> PgClassExpression60
    First65{{"First[65∈6]^"}}:::plan
    PgSelectRows66[["PgSelectRows[66∈6]^"]]:::plan
    PgSelectRows66 --> First65
    PgSelect61 --> PgSelectRows66
    PgSelectSingle67{{"PgSelectSingle[67∈6]^<br />ᐸpeopleᐳ"}}:::plan
    First65 --> PgSelectSingle67
    PgSelectSingle47 --> PgClassExpression69
    First72{{"First[72∈6]^"}}:::plan
    PgSelectRows73[["PgSelectRows[73∈6]^"]]:::plan
    PgSelectRows73 --> First72
    PgSelect70 --> PgSelectRows73
    PgSelectSingle74{{"PgSelectSingle[74∈6]^<br />ᐸpostsᐳ"}}:::plan
    First72 --> PgSelectSingle74
    PgClassExpression75{{"PgClassExpression[75∈6]^<br />ᐸ__comments__.”body”ᐳ"}}:::plan
    PgClassExpression50 o--o PgClassExpression75
    PgClassExpression76{{"PgClassExpression[76∈7]<br />ᐸ__people__.”username”ᐳ<br />ᐳPost"}}:::plan
    PgSelectSingle59 --> PgClassExpression76
    PgClassExpression77{{"PgClassExpression[77∈8]<br />ᐸ__people__.”username”ᐳ<br />ᐳComment"}}:::plan
    PgSelectSingle67 --> PgClassExpression77
    PgClassExpression79{{"PgClassExpression[79∈9]<br />ᐸ__posts__.”body”ᐳ<br />ᐳComment"}}:::plan
    PgSelectSingle74 --> PgClassExpression79

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect7,Access8,Access9,Object10,PgFromExpression11,__ListTransform12,PgSelectRows13 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item14,PgSelectSingle15 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,__Item16,PgSelectSingle17,PgClassExpression18,PgClassExpression19,PgClassExpression20,List21,Lambda22,Access23 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,Access24,PgSelect25,First29,PgSelectRows30,PgSelectSingle31,PgClassExpression48,PgClassExpression51 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,Access32,PgSelect33,First37,PgSelectRows38,PgSelectSingle39,PgClassExpression49,PgClassExpression52,PgSelect53,First57,PgSelectRows58,PgSelectSingle59,PgClassExpression68 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,Access40,PgSelect41,First45,PgSelectRows46,PgSelectSingle47,PgClassExpression50,PgClassExpression60,PgSelect61,First65,PgSelectRows66,PgSelectSingle67,PgClassExpression69,PgSelect70,First72,PgSelectRows73,PgSelectSingle74,PgClassExpression75 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,PgClassExpression76 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8,PgClassExpression77 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgClassExpression79 bucket9

